import CustomizeException.PassWordException;
import CustomizeException.UserNameException;

public class ExceptionText {
   static class  Login {
        public String userName = "admit";
        public String passWord= "123456";
        public void Login(String userName, String passWord) {
            if(!this.userName.equals(userName)){
                System.out.println("用户名错误!");
                throw new UserNameException("用户名错误！");
            }
            if(!this.passWord.equals(passWord)){
                System.out.println("密码错误!");
                throw new PassWordException("密码错误！");
            }
        }
    }
    public  static void main(String[] args) {
       try {
           Login login = new Login();
           login.Login("admi", "123456");
           System.out.println("密码正确");
       } catch (UserNameException e) {
           System.out.println("捕捉到了用户名异常...");
           e.printStackTrace();
       } catch (PassWordException e) {
           System.out.println("捕捉到了密码异常...");
           e.printStackTrace();
       } finally {
           System.out.println("程序继续执行");
       }
    }
}
